Skip to content

[Symfony] Set few default common service names for Symfony App Analyzer#1687

Merged
TomasVotruba merged 1 commit intorectorphp:masterfrom
stloyd:symfony-app-analyzed
Jul 4, 2019
Merged

[Symfony] Set few default common service names for Symfony App Analyzer#1687
TomasVotruba merged 1 commit intorectorphp:masterfrom
stloyd:symfony-app-analyzed

Conversation

@stloyd
Copy link
Copy Markdown
Contributor

@stloyd stloyd commented Jul 4, 2019

Allow to set custom ones via configuration:

# rector.yaml
services:
  Rector\Symfony\Bridge\DefaultAnalyzedSymfonyApplicationContainer:
    autowire: true
    arguments:
      $commonNamesToTypes:
        'doctrine.orm.other_entity_manager': Doctrine\ORM\EntityManagerInterface
        'pseudo.buggy.service_name': App\Some\ServiceClass

@stloyd stloyd force-pushed the symfony-app-analyzed branch from 166d2a7 to 325a6d7 Compare July 4, 2019 11:43
/**
* @param ParameterProvider $parameterProvider
* @param SymfonyKernelParameterGuard $symfonyKernelParameterGuard
* @param ContainerFactory $containerFactory
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be no duplicated for PHP code info.
The sniff is disabled for this, because it was doing to much

$this->parameterProvider = $parameterProvider;
$this->symfonyKernelParameterGuard = $symfonyKernelParameterGuard;
$this->containerFactory = $containerFactory;
$this->commonNamesToTypes = array_merge($this->commonNamesToTypes, $commonNamesToTypes);
Copy link
Copy Markdown
Member

@TomasVotruba TomasVotruba Jul 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this needed for? Default names should not depend on custom user input, but on default Symfony naming.

The point is 0-configuration. So services are loaded from the App container itself and we don't bother user to basically copy-paste it to rector.yaml config :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Problem is for example that by default container says that: doctrine.orm.entity_manager is instance of Doctrine\Common\Persistence\ObjectManager, which in fact is not really true, cause it's instance of Doctrine\ORM\EntityManagerInterface (which is also used for autowire functionality).

This is just one example, if there is more edge cases (in big legacy like we have, we can occur them most likely), user is not able to have automatic fix for such cases and he/she will be forced to fix it manually.

With this you can have most common known cases for replacement, but also user is able to not wait for new release of Rector if he/she finds another edge case.

Copy link
Copy Markdown
Member

@TomasVotruba TomasVotruba Jul 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just one example, if there is more edge cases (in big legacy like we have, we can occur them most likely), user is not able to have automatic fix for such cases and he/she will be forced to fix it manually.

I see. It makes sense now :) 👍

I miss this description on PR. Could you add it next time, so I can read the code with context of your intention? It would speed up the review

@stloyd stloyd force-pushed the symfony-app-analyzed branch from 325a6d7 to 6d23c75 Compare July 4, 2019 11:55
@TomasVotruba TomasVotruba self-requested a review July 4, 2019 12:43
@TomasVotruba TomasVotruba merged commit 6574c11 into rectorphp:master Jul 4, 2019
@stloyd stloyd deleted the symfony-app-analyzed branch July 4, 2019 12:47
TomasVotruba added a commit that referenced this pull request Jan 16, 2022
rectorphp/rector-src@ca696bc [DowngradePhp74] Do not remove non-null default value on nullable on DowngradeTypedPropertyRector (#1687)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants